package com.hongshu.web.controller.sys;

import com.hongshu.common.core.web.controller.BaseController;
import com.hongshu.common.core.web.domain.AjaxResult;
import com.hongshu.web.service.sys.ISysDashboardService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页RestApi
 *
 * @author: hongshu
 * @date 2018年10月22日下午3:27:24
 */
@RestController
@RequestMapping("/index")
@Tag(name = "首页相关接口", description = "首页相关接口")
@Slf4j
public class SysDashboardController extends BaseController {

    @Autowired
    private ISysDashboardService dashboardService;


    @Operation(summary = "首页初始化数据", description = "首页初始化数据")
    @RequestMapping(value = "/init", method = RequestMethod.GET)
    public AjaxResult init() {
        return success(dashboardService.getInitData());
    }

    @Operation(summary = "获取最近一周用户独立IP数和访问量", description = "获取最近一周用户独立IP数和访问量")
    @RequestMapping(value = "/getVisitByWeek", method = RequestMethod.GET)
    public AjaxResult getVisitByWeek() {
        return success(dashboardService.getVisitByWeek());
    }

    @Operation(summary = "获取每个标签下文章数目", description = "获取每个标签下文章数目")
    @RequestMapping(value = "/getNoteCountByType", method = RequestMethod.GET)
    public AjaxResult getBlogCountByTag() {
        return success(dashboardService.getNoteCountByType());
    }

    @Operation(summary = "获取每个类型下商品数目", description = "获取每个类型下商品数目")
    @RequestMapping(value = "/getProductCountByType", method = RequestMethod.GET)
    public AjaxResult getProductCountByType() {
        return success(dashboardService.getProductCountByType());
    }

    @Operation(summary = "获取订单数据", description = "获取订单数据")
    @RequestMapping("/getOrderData")
    public AjaxResult getOrderData() {
        return success(dashboardService.getOrderDataByWeek());
    }

    @Operation(summary = "获取每日新增数据", description = "获取每日新增数据")
    @RequestMapping("/getDailyNewData")
    public AjaxResult getDailyNewData() {
        return success(dashboardService.getDailyNewData());
    }

    @Operation(summary = "获取每个分类下文章数目", description = "获取每个分类下文章数目")
    @RequestMapping(value = "/getBlogCountByBlogSort", method = RequestMethod.GET)
    public AjaxResult getBlogCountByBlogSort() {
        return success(dashboardService.getNoteCountByCategory());
    }

    @Operation(summary = "获取每个分类下文章数目", description = "获取每个分类下文章数目")
    @RequestMapping(value = "/getProductByBlogSort", method = RequestMethod.GET)
    public AjaxResult getProductByBlogSort() {
        return success(dashboardService.getProductCountByCategory());
    }

    @Operation(summary = "获取一年内的文章贡献数", description = "获取一年内的文章贡献度")
    @RequestMapping(value = "/getBlogContributeCount", method = RequestMethod.GET)
    public AjaxResult getBlogContributeCount() {
        return success(dashboardService.getNoteContributeCount());
    }

    @Operation(summary = "获取热门内容", description = "获取热门内容")
    @RequestMapping(value = "/getHotNote", method = RequestMethod.GET)
    public AjaxResult getHotNote(String noteType) {
        return success(dashboardService.getHotNote(noteType));
    }

    @Operation(summary = "获取用户地理位置分布", description = "获取用户地理位置分布")
    @RequestMapping(value = "/getUserLocations", method = RequestMethod.GET)
    public AjaxResult getUserLocations() {
        return success(dashboardService.getUserLocations());
    }
}
